package pro.softzhang.algo.lc300;

import com.alibaba.fastjson.JSON;
import pro.softzhang.algo.flag.knowledge.KDoublePointer;
import pro.softzhang.algo.flag.knowledge.KString;

/**
 *
 * https://leetcode.cn/problems/reverse-string/
 */
@KString
public class LC344_ReverseString {
    public static void main(String[] args) {
        String s = "hello";
        char[] chs = s.toCharArray();
        new Solution().reverseString(chs);
        System.out.println(JSON.toJSONString(chs));
    }

    @KDoublePointer
    static
    class Solution {
        public void reverseString(char[] s) {
            for (int i = 0, j = s.length - 1; i < j; i++, j--) {
                char ch = s[i];
                s[i] = s[j];
                s[j] = ch;
            }
        }
    }
}
